home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / Draw / Sources / InsrtCmd.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  3.8 KB  |  125 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                InsrtCmd.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #include "ODFDraw.hpp"
  13.  
  14. #ifndef INSERTCMD_H
  15. #include "InsrtCmd.h"
  16. #endif
  17.  
  18. #ifndef DRAWSEL_H
  19. #include "DrawSel.h"
  20. #endif
  21.  
  22. #ifndef DRAWFRM_H
  23. #include "DrawFrm.h"
  24. #endif
  25.  
  26. #ifndef DRAWCONT_H
  27. #include "DrawCont.h"
  28. #endif
  29.  
  30. //========================================================================================
  31. // RunTime Info
  32. //========================================================================================
  33.  
  34. #ifdef FW_BUILD_MAC
  35. #pragma segment odfdrawcommand
  36. #endif
  37.  
  38.  
  39. FW_DEFINE_AUTO(CDrawInsertCommand)
  40.  
  41. //========================================================================================
  42. // CDrawInsertCommand
  43. //========================================================================================
  44.  
  45. //----------------------------------------------------------------------------------------
  46. //    CDrawInsertCommand constructor
  47. //----------------------------------------------------------------------------------------
  48.  
  49. CDrawInsertCommand::CDrawInsertCommand(Environment *ev, 
  50.                                         CDrawFrame* frame, 
  51.                                         const FW_PFileSpecification& fileSpec, 
  52.                                         CDrawSelection* selection,
  53.                                         FW_Boolean canUndo) :
  54.     FW_CInsertCommand(ev, frame, fileSpec, canUndo),
  55.     fUndoContent(NULL),
  56.     fDrawSelection(selection)
  57. {
  58.     FW_END_CONSTRUCTOR
  59. }
  60.  
  61. //----------------------------------------------------------------------------------------
  62. //    CDrawInsertCommand destructor
  63. //----------------------------------------------------------------------------------------
  64.  
  65. CDrawInsertCommand::~CDrawInsertCommand()
  66. {
  67.     FW_START_DESTRUCTOR
  68.     delete fUndoContent;
  69. }
  70.  
  71. //----------------------------------------------------------------------------------------
  72. //    CDrawInsertCommand::PreCommand
  73. //----------------------------------------------------------------------------------------
  74.  
  75. void CDrawInsertCommand::PreCommand(Environment *ev)
  76. {
  77.     fDrawSelection->CloseSelection(ev);
  78. }
  79.  
  80. //----------------------------------------------------------------------------------------
  81. //    CDrawInsertCommand::CommandDone
  82. //----------------------------------------------------------------------------------------
  83.  
  84. void CDrawInsertCommand::CommandDone(Environment *ev)
  85. {
  86.     fDrawSelection->CenterSelection(ev, GetFrame(ev));
  87. }
  88.  
  89. //----------------------------------------------------------------------------------------
  90. //    CDrawInsertCommand::SaveRedoState
  91. //----------------------------------------------------------------------------------------
  92.  
  93. void CDrawInsertCommand::SaveRedoState(Environment *ev)
  94. {
  95.     FW_ASSERT(fUndoContent == NULL);
  96.     fUndoContent = FW_NEW(CDrawUndoContent, (ev, fDrawSelection->GetDrawPart(), fDrawSelection));
  97. }
  98.  
  99. //----------------------------------------------------------------------------------------
  100. //    CDrawInsertCommand::FreeRedoState
  101. //----------------------------------------------------------------------------------------
  102.  
  103. void CDrawInsertCommand::FreeRedoState(Environment* ev)
  104. {
  105.     fUndoContent->DeleteSavedShapes(ev);
  106. }
  107.  
  108. //----------------------------------------------------------------------------------------
  109. //    CDrawInsertCommand::UndoIt
  110. //----------------------------------------------------------------------------------------
  111.  
  112. void CDrawInsertCommand::UndoIt(Environment *ev)
  113. {
  114.     fUndoContent->RemoveShapeSelection(ev);
  115. }
  116.  
  117. //----------------------------------------------------------------------------------------
  118. //    CDrawInsertCommand::RedoIt
  119. //----------------------------------------------------------------------------------------
  120.  
  121. void CDrawInsertCommand::RedoIt(Environment *ev)
  122. {
  123.     fUndoContent->RestoreShapeSelection(ev);
  124. }
  125.